---
layout: "default"
root: "/v5.1"
title: "ExpressibleByStringLiteral"
keywords: ""
description: "Swift documentation for 'ExpressibleByStringLiteral'"
---

<div class="intro-declaration"><code class="language-swift">protocol ExpressibleByStringLiteral</code></div><p>A type that can be initialized with a string literal.</p>
<table class="standard"><tr><th id="inheritance">Inheritance</th><td><code class="inherits">ExpressibleByExtendedGraphemeClusterLiteral</code></td></tr><tr><th id="conforming-types">Conforming Types</th><td><code class="inherits">ExpressibleByStringInterpolation, StaticString, String, Substring</code></td></tr><tr><th id="associatedtypes">Associated Types</th><td><span id="aliasesmark"></span><div class="declaration"><code class="language-swift">associatedtype StringLiteralType</code><div class="comment"><p>Valid types for <code>StringLiteralType</code> are <code>String</code> and <code>StaticString</code>.</p>
</div></div></td></tr></table><div class="discussion comment"><p>The <code>String</code> and <code>StaticString</code> types conform to the
<code>ExpressibleByStringLiteral</code> protocol. You can initialize a variable or
constant of either of these types using a string literal of any length.</p>
<pre><code class="language-swift">let picnicGuest = &quot;Deserving porcupine&quot;
</code></pre>
<h3>Conforming to ExpressibleByStringLiteral</h3>
<p>To add <code>ExpressibleByStringLiteral</code> conformance to your custom type,
implement the required initializer.</p>
</div><h3>Initializers</h3><div id="init_stringLiteral-a150a34163a566e92846a108f6703cde" class="declaration"><a class="toggle-link" href="#comment-init_stringLiteral-a150a34163a566e92846a108f6703cde">init init(stringLiteral:)</a> <span class="required">Required</span><div class="comment collapse in" id="comment-init_stringLiteral-a150a34163a566e92846a108f6703cde"><p>Creates an instance initialized to the given string value.</p>
<ul>
<li>Parameter value: The value of the new instance.</li>
</ul>
<h4>Declaration</h4><code class="language-swift">init(stringLiteral value: Self.StringLiteralType)</code></div></div>